import socket
udp_client_socket=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
server=('127.0.0.1',8000)
def main():
    while True:
        msg=input('>>>>>').encode('utf-8')
        if msg.upper()=='Q':
            break
        udp_client_socket.sendto(msg,server)
        msg=udp_client_socket.recv(1024)
        if msg.upper()=='Q':
            break
        print(msg.decode('utf-8'))

    udp_client_socket.close()
if __name__ == '__main__':
    main()